import axios from 'axios'
import { ElMessage } from 'element-plus'
import { reactive } from 'vue'

const axiosHelper = reactive({
    read: axios.create({
        baseURL: 'http://localhost:5299/', // Vite 环境变量
        timeout: 100000,
    }),
    write: axios.create({
        baseURL: 'http://localhost:5070/', // Vite 环境变量
        timeout: 100000,
    })
    
})

for (const prop in axiosHelper) {
    axiosHelper[prop].interceptors.request.use(
        (config: any) => {
            return config;
        },
        (eroor: any) => {
            return Promise.reject(eroor);
        }
    ),
    axiosHelper[prop].interceptors.response.use(
        (res: any) => {
            return res;
        },
        (eroor: any) => {
            return Promise.reject(eroor);
        }
    )
}

export default axiosHelper
